package cn.ilovese.collect.controller.report;

import cn.ilovese.collect.service.report.ScoreService;
import cn.ilovese.collect.vo.NullVO;
import cn.ilovese.collect.vo.OthersEvaluateAbilityVO;
import cn.ilovese.collect.vo.ResultVO;
import cn.ilovese.collect.vo.report.*;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/score")
public class ScoreController {
    @Resource
    ScoreService scoreService;


    //众包测试工人对报告评分和评价
    @PostMapping("/postScore")
    public ResultVO<ScoreVO> postScoreOfReport(@RequestBody ScoreVO scoreVO){
        return scoreService.postScoreOfReport(scoreVO);
    }

    //众包测试工人对报告的评分和评价进行删除
    @GetMapping("/deleteScore/{commentid}")
    public ResultVO<NullVO> deleteScoreOfReport(@PathVariable Integer commentid){
        return scoreService.deleteScoreOfReport(commentid);
    }

    //众包测试工人得到工人评分
    @GetMapping("/getMyScore/{reportid}")
    public ResultVO<ScoreVO> getMyScoreOfReport(@PathVariable Integer reportid,@RequestParam Integer workerid){
        return scoreService.getMyScoreOfReport(reportid,workerid);
    }

    //众包测试工人对报告的评分和评价进行更新
    @PostMapping("/updateScore")
    public ResultVO<ScoreVO> updateScoreOfReport(@RequestBody ScoreVO scoreVO){
        return scoreService.updateScoreOfReport(scoreVO);
    }

    //获取一个报告所有的评分和评价
    @GetMapping("/getScores/{reportid}")
    public ResultVO<ScoreAllVO> getScoresOfReport(@PathVariable Integer reportid,@RequestParam Integer loginid){
        return scoreService.getScoresOfReport(reportid,loginid);
    }

    @GetMapping("/getCompreScore/{reportid}")
    public ResultVO<ComprehensiveScoreVO> getCompreScoreOfReport(@PathVariable Integer reportid){
        return scoreService.getCompreScoreOfReport(reportid);
    }
    //ResultVO<NullVO> likeScore(Integer userid,Integer commentid);
    //对评价点赞
    @PostMapping("/like")
    public ResultVO<NullVO> likeScore(@RequestParam Integer userid,@RequestParam Integer commentid){
        return scoreService.likeScore(userid,commentid);
    }
    //ResultVO<NullVO> unlikeScore(Integer userid,Integer commentid);
    //对评价取消点赞
    @PostMapping("/unlike")
    public ResultVO<NullVO> unlikeScore(@RequestParam Integer userid,@RequestParam Integer commentid){
        return scoreService.unlikeScore(userid,commentid);
    }

    //ResultVO<BossScoreVO> postBossScoreOfReport(BossScoreVO bossScoreVO);
    //发包方对报告评价
    @PostMapping("/postBossScore")
    public ResultVO<BossScoreVO> postBossScoreOfReport(@RequestBody BossScoreVO bossScoreVO){
        return scoreService.postBossScoreOfReport(bossScoreVO);
    }

    //ResultVO<NullVO> deleteBossScoreOfReport(Integer commentid);
    //发包方对报告的评价进行删除
    @GetMapping("/deleteBossScore/{commentid}")
    public ResultVO<NullVO> deleteBossScoreOfReport(@PathVariable Integer commentid){
        return scoreService.deleteBossScoreOfReport(commentid);
    }

    //ResultVO<BossScoreVO> getBossScoreOfReport(Integer reportid,Integer bossid);
    //获得发包方评分
        @GetMapping("/getBossScore/{reportid}")
    public ResultVO<BossScoreVO> getBossScoreOfReport(@PathVariable Integer reportid){
        return scoreService.getBossScoreOfReport(reportid);
    }

    //ResultVO<BossScoreVO> updateBossScoreOfReport(BossScoreVO bossScoreVO);
    //发包方对报告的评价进行更新
    @PostMapping("/updateBossScore")
    public ResultVO<BossScoreVO> updateBossScoreOfReport(@RequestBody BossScoreVO bossScoreVO){
        return scoreService.updateBossScoreOfReport(bossScoreVO);
    }

    @GetMapping("/ability/{userid}")
    public ResultVO<ScoreAbilityVO> getGeneralScoreAbility(@PathVariable Integer userid){
        return scoreService.getGeneralScoreAbility(userid);
    }

    @GetMapping("/othersEvaluteAbility/{workerid}")
    public ResultVO<OthersEvaluateAbilityVO> getOthersEvaluateAbility(@PathVariable Integer workerid){
        return scoreService.getOthersEvaluateAbility(workerid);
    }

    @GetMapping("/recommendReport/{userid}")
    public ResultVO<List<ReportWithWorkerNameVO>> getRecommendReports(@PathVariable Integer userid){
        return scoreService.getRecommendReports(userid);
    }

}
